package behavioral.memento;

/**
 * @ClassName: MainTest
 * @Description: 测试类
 * @Author: liu-hao
 * @Date: 2023-04-11 23:17
 * @Version: 1.0
 **/
public class MainTest {
    public static void main(String[] args) {
        // 发起人
        Originator originator = new Originator("Tom", 20);
        originator.display();

        // 备忘录管理者
        Caretaker caretaker = new Caretaker();
        caretaker.saveMemento(originator.createMemento()); // 创建备忘录

        // 修改状态
        originator = new Originator("Jerry", 25);
        originator.display();

        // 恢复状态
        originator.setMemento(caretaker.retrieveMemento());
        originator.display();
    }
}
